<?php

//********************************
//	File:		controller.php
//	Author:		Philip Pryce
//	Date:		20th July 2008
//	Comments:	
//********************************


class Controller {
	
	var $__data = array();
	
	function __construct () {
		
		
	}
	
	function _assign ($keys, $value='') {
		
		if (is_array($keys)) {
			foreach ($keys as $key => $value) {
				$this->__data[$key] = $value;
			}
			return;
		}
		$this->__data[$keys] = $value;
		return;
	} 
	
	function _load ($_view) {
		
		if (file_exists(APP . 'views/' . $_view . '.php')) {
			
			foreach ($this->__data as $key => $value) {
				${$key} = $value;
			}
			
			require_once(APP . 'views/' . $_view . '.php');
			return;
			
		}
		else {
			displayError(ERROR_FATAL, 'Controller->_load', 'View "' . $_view . '" doesnt exist in "' . APP . 'views/' . $_view . '.php"');
			return false;
		}
		
	}
	
	function __destruct () {
		
		foreach(get_object_vars($this) as $key => $value) {
			// destroy all the objects in here when we die.
			unset($key);
		}
		
	}
	
}

?>